{template 'header', $module}
<script src="{SITE_URL}file/script/config.js"></script>
<script src="{SITE_URL}file/script/common.js"></script>
<link rel="stylesheet" type="text/css" href="image/chat.css"/>
{if $type == 3}
<div class="main-block bd-gray">
<div class="hd fn-clear">
	<h2 class="fn-left">发起对话</h2>
</div>
<ul id="data-nav" class="main-nav mt10 fn-clear">
	<li id="status_"><a href="javascript:void(0);" onfocus="this.blur();"><span><img class='fn-left mt5 mr5' src="image/add_bg.gif" width="12" height="12" align="absmiddle"/> 发起新对话</span></a></li>
	<li id="status_1"><a href="javascript:void(0);" onfocus="this.blur();"><span>收到的对话<span class="px10">({count($T)})</span></span></a></li>
	<li id="status_2"><a href="javascript:void(0);" onfocus="this.blur();"><span>发起的对话<span class="px10">({count($F)})</span></span></a></li>
</ul>
<table id="data-tb" class="data-form c666 con mt10">
	<tbody id="status_con_">
	<form action="chat.php" id="pub-form" target="_blank" >
		<tr>
			<th width="90"><label for="touser"><span class="cred">*</span> 输入会员名：</label></th>
			<td width="640"><input type="text" size="20" name="touser" class="graybd-ipt easyui-validatebox" data-options="required:true,missingMessage:'请输入会员名'" />
		</tr>
		<tr>
			<th width="90"></th>
			<td class="sub-info" width="640">
				<button type="submit" class="btn">开始对话</button>
				<span id="dtouser" class="cred"></span>
			</td>
		</tr>
	</form>
	<script type="text/javascript">
		seajs.use(['$'], function ($) {
			$('#pub-form').on('submit', function(){
				return $('#pub-form').form('validate');
			});
		})
	</script>
	</tbody>
	<tbody id="status_con_1" class="dialog-list fn-hide">
	{if $T}
	<tr>
		<th width="100">发起人</th>
		<th width="100">来自</th>
		<th width="100">姓名</th>
		<th width="100">状态</th>
		<th width="150">时间</th>
		<th width="100">操作</th>
		<th width="60">来源页面</th>
	</tr>
	{loop $T $v}
	<tr>
		<td height="25" align="left">&nbsp;&nbsp;
			<img src="image/ico_newchat.gif" align="absmiddle"/>&nbsp;{$v[fromuser]}
		</td>
		<td>{if $v[linkurl]}<a href="{$v[linkurl]}" class="t" target="_blank">{/if}{$v[from]}{if $v[linkurl]}</a>{/if}</td>
		<td>{$v[truename]}</td>
		<td>{$S[$v[status]]}</td>
		<td>{$v[addtime]}</td>
		<td>
			{if $v[status] == 0}
			<a href="chat.php?chatid={$v[chatid]}" target="chat_{$v[chatid]}" class="t">查看</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=del" onclick="return confirm('确定要删除此对话吗？');" class="t">删除</a>
			{elseif $v[status] == 1}
			<a href="chat.php?chatid={$v[chatid]}&action=del" onclick="return confirm('确定要删除此对话吗？');" class="t">删除</a>
			{elseif $v[status] == 2}
			<a href="chat.php?chatid={$v[chatid]}" target="chat_{$v[chatid]}" class="t">接受</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=deny" onclick="return confirm('确定要拒绝此对话吗？');" class="t">拒绝</a>
			{elseif $v[status] == 3}
			<a href="chat.php?chatid={$v[chatid]}" target="chat_{$v[chatid]}" class="t">查看</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=off" onclick="return confirm('确定要断开此对话吗？');" class="t">断开</a>
			{elseif $v[status] == 4}
			<a href="chat.php?chatid={$v[chatid]}" target="chat_{$v[chatid]}" class="t">查看</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=del" onclick="return confirm('确定要删除此对话吗？');" class="t">删除</a>
			{/if}
		</td>
		<td>
			{if $v[forward]}
			<a href="{$v[forward]}" target="_blank" class="t">点击访问</a>
			{else}
			---
			{/if}
		</td>
	</tr>
	{/loop}
	{else}
	<tr>
		<td class="nobd">{if $_username}暂未收到对话请求，或者对话请求已经过期{else}您还没有登录，无法收到对话请求{/if}</td>
	</tr>
	{/if}
	</tbody>
	<tbody id="status_con_2" class="dialog-list fn-hide">
	{if $F}
	<tr>
		<th>接收人</th>
		<th>来自</th>
		<th>姓名</th>
		<th>状态</th>
		<th width="150">时间</th>
		<th width="100">操作</th>
		<th width="60">来源页面</th>
	</tr>
	{loop $F $v}
	<tr>
		<td height="25" align="left">&nbsp;&nbsp;
			<img src="image/ico_newchat.gif" align="absmiddle"/>&nbsp;{$v[touser]}
		</td>
		<td><a href="{$v[linkurl]}" class="t" target="_blank">{$v[from]}</a></td>
		<td>{$v[truename]}</td>
		<td>{$S[$v[status]]}</td>
		<td>{$v[addtime]}</td>
		<td>
			{if $v[status] == 0}
			<a href="chat.php?touser={$v[touser]}" target="chat_{$v[touser]}" class="t">查看</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=del&tab=2" onclick="return confirm('确定要删除此对话吗？');" class="t">删除</a>
			{elseif $v[status] == 1}
			--
			{elseif $v[status] == 2}
			<a href="chat.php?touser={$v[touser]}" target="chat_{$v[touser]}" class="t">查看</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=del&tab=2" onclick="return confirm('确定要删除此对话吗？');" class="t">删除</a>
			{elseif $v[status] == 3}
			<a href="chat.php?touser={$v[touser]}" target="chat_{$v[touser]}" class="t">查看</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=off&tab=2" onclick="return confirm('确定要断开此对话吗？');" class="t">断开</a>
			{elseif $v[status] == 4}
			<a href="chat.php?touser={$v[touser]}" target="chat_{$v[touser]}" class="t">连接</a> |
			<a href="chat.php?chatid={$v[chatid]}&action=del&tab=2" onclick="return confirm('确定要删除此对话吗？');" class="t">删除</a>
			{/if}
		</td>
		<td>
			{if $v[forward]}
			<a href="{$v[forward]}" target="_blank" class="t">点击访问</a>
			{else}
			---
			{/if}
		</td>
	</tr>
	{/loop}
	{else}
	<tr>
		<td class="nobd">暂未发起对话请求</td>
	</tr>
	{/if}
	</tbody>
</table>
{else}
<script type="text/javascript">
	var chat_id = '{$chat_id}';
	var chat_poll = {$chat_poll};
	var chat_maxlen = {$MOD[chat_maxlen]};
	var chat_mintime = {$MOD[chat_mintime]};
	var chat_status = {$chat_status};
	var chat_type = {$type};
	var chat_last = {$DT_TIME};
	var chat_title = document.title;
	var chat_lang = {
		ec1 : '按Enter键发送消息，按Ctrl+Enter键换行',
		ec2 : '按Ctrl+Enter键发送消息，按Enter键换行',
		tip : '提示：系统不长久保存您的对话记录，关闭对话窗口将可能导致记录丢失，如果需要保存，请在交谈完毕之后点保存按钮',
		last : 'ok'
	};
</script>

<iframe src="" name="send" id="send" style="display:none;"></iframe>
<div class="chat-block fn-left">

<div id="chat"></div>
<div id="font" style="display:none;">
	<table cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td width="8" height="30"></td>
			<td width="120">
				<select id="font_s" onchange="font_init();">
					<option value="0">大小</option>
					<option value="10">10</option>
					<option value="11">11</option>
					<option value="12">12</option>
					<option value="13">13</option>
					<option value="14">14</option>
					<option value="16">16</option>
					<option value="18">18</option>
					<option value="20">20</option>
					<option value="24">24</option>
				</select>&nbsp;
				<select id="font_c" onchange="font_init();">
					<option value="0">颜色</option>
					<option value="1" style="background:#000000;">黑</option>
					<option value="2" style="background:#FF0000;">红</option>
					<option value="3" style="background:#0000FF;">蓝</option>
					<option value="4" style="background:#008040;">绿</option>
					<option value="5" style="background:#FF6600;">橙</option>
					<option value="6" style="background:#FF00FF;">粉</option>
				</select>
			</td>
			<td class="tool_a" id="tool_font_b" onclick="this.className=this.className=='tool_a' ? 'tool_b' : 'tool_a';font_init();"><img src="image/chat_font_b.gif" width="16" height="16" title="加粗"/></td>
			<td class="tool_a" id="tool_font_i" onclick="this.className=this.className=='tool_a' ? 'tool_b' : 'tool_a';font_init();"><img src="image/chat_font_i.gif" width="16" height="16" title="倾斜"/></td>
			<td class="tool_a" id="tool_font_u" onclick="this.className=this.className=='tool_a' ? 'tool_b' : 'tool_a';font_init();"><img src="image/chat_font_u.gif" width="16" height="16" title="下划线"/></td>
			<td>&nbsp;</td>
			<td class="c_p" width="15" onclick="font_hide();" title="点击关闭"><img src="image/close.gif"/></td>
		</tr>
	</table>
</div>
<div id="tool">
	<table cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td width="4">
				<div id="face" style="display:none;">
					<div><span onclick="face_hide();" title="点击关闭"><img src="image/close.gif"/></span><strong>选择表情</strong></div>
					{if $faces}
					<table cellspacing="0" cellpadding="0" title="点击选择">
						{loop $faces $k $v}
						{if $k%10==0}
						<tr>{/if}
							<td onmouseover="this.style.backgroundColor='#E3EEF3';" onmouseout="this.style.backgroundColor='';"><img src="face/{$v}.gif" onclick="face_into('{$v}');"/></td>
							{if $k%10==9}
						</tr>
						{/if}
						{/loop}
					</table>
					{/if}
				</div>
			</td>
			<td class="tool_a" onmouseover="this.className='tool_b';" onmouseout="if(Dd('font').style.display=='none')this.className='tool_a';" id="tool_font" onclick="font_show();"><img src="image/chat_font.gif" width="16" height="16" title="设置文字颜色和格式"/></td>
			{if $faces}
			<td class="tool_a" onmouseover="this.className='tool_b';" onmouseout="if(Dd('face').style.display=='none')this.className='tool_a';" id="tool_face" onclick="face_show();"><img src="image/chat_face.gif" width="16" height="16" title="表情"/></td>
			{/if}
			<td>&nbsp;</td>
			<td class="tool_a" onmouseover="this.className='tool_b';" onmouseout="this.className='tool_a';" id="tool_log" onclick="chat_log();"><img src="image/chat_log.gif" width="16" height="16" title="查看对话记录"/></td>
			<td class="tool_a" onmouseover="this.className='tool_b';" onmouseout="this.className='tool_a';" id="tool_save" onclick="chat_save();"><img src="image/chat_save.gif" width="16" height="16" title="保存对话记录"/></td>
			<td class="tool_a" onmouseover="this.className='tool_b';" onmouseout="this.className='tool_a';" id="tool_clear" onclick="Dd('chat').innerHTML='';"><img src="image/chat_clear.gif" width="16" height="16" title="清屏"/></td>
		</tr>
	</table>
</div>
<div class="word"><textarea id="word" onkeydown="return chat_key(event);" onfocus="Dh('ec');font_hide();face_hide();new_tip_stop();" class="f_gray" onclick="if(this.value==chat_lang.tip)this.value='';this.className='';"></textarea>
	<script type="text/javascript">Dd('word').value = chat_lang.tip;</script>
</div>
<div id="btns">
	<table cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td width="5"><img src="image/chat_foot_l.gif" width="5" height="30"/></td>
			<td>
				<div id="tip" style="display:none;"></div>
			</td>
			<td>&nbsp;</td>
			<td width="62"><img src="image/chat_c1.gif" width="69" height="21" onmouseover="this.src='image/chat_c2.gif';" onmouseout="this.src='image/chat_c1.gif';" onclick="chat_off();"/></td>
			<td width="8"></td>
			<td width="62"><img src="image/chat_s1.gif" width="62" height="21" onmouseover="this.src='image/chat_s2.gif';" onmouseout="this.src='image/chat_s1.gif';" onclick="chat_send();" id="chat_s"/></td>
			<td width="21">
				<div id="ec" style="display:none;" onmouseover="Ds('ec');" onmouseout="Dh('ec');">
					<span id="ec1"><a href="javascript:ec_set(1);">按Enter键发送消息</a></span>
					<span id="ec2"><a href="javascript:ec_set(2);">按Ctrl+Enter键发送消息</a></span>
				</div>
				<img src="image/chat_e1.gif" width="21" height="21" onmouseover="this.src='image/chat_e2.gif';" onmouseout="this.src='image/chat_e1.gif';" onclick="Ds('ec');"/></td>
			<td width="5"><img src="image/chat_foot_r.gif" width="5" height="30"/></td>
		</tr>
	</table>
</div>
<div id="sd"></div>
</div>

<div class="chat-info fn-right">
	<div class="i_head">
		<strong>对方信息</strong>
	</div>
	<div class="i_body">
		<div class="i_user">
			<table cellpadding="6" cellspacing="0" width="100%">
				{if $user[type] == 'guest'}
				<tr>
					<td class="i_user_l">会员类型</td>
					<td>游客</td>
				</tr>
				<tr>
					<td class="i_user_l">所在IP</td>
					<td>{$user[ip]}</td>
				</tr>
				<tr>
					<td class="i_user_l">所在地区</td>
					<td>{$user[area]}</td>
				</tr>
				{else}
				<tr>
					<td class="i_user_l">企业名称：</td>
					<td><a href="{$user[linkurl]}" target="_blank" class="l">{$user[company]}</a></td>
				</tr>
				<tr>
					<td class="i_user_l">在线状态：</td>
					<td>{if online($user[userid])==1}<font class="cred">当前在线</font>{else}<font class="f_gray">当前离线</font>{/if}</td>
				</tr>
				<tr>
					<td class="i_user_l">企业地址：</td>
					<td>{$user[address]}&nbsp;</td>
				</tr>
				{if $user[postcode]}
				<tr>
					<td class="i_user_l">邮政编码：</td>
					<td>{$user[postcode]}</td>
				</tr>
				{/if}
				<tr>
					<td class="i_user_l">企业电话：</td>
					<td>{$user[telephone]}</td>
				</tr>
				{if $user[fax]}
				<tr>
					<td class="i_user_l">企业传真：</td>
					<td>{$user[fax]}</td>
				</tr>
				{/if}
				{if $user[mail]}
				<tr>
					<td class="i_user_l">电子邮件：</td>
					<td>{$user[mail]}</td>
				</tr>
				{/if}
				{if $user[truename]}
				<tr>
					<td class="i_user_l">联 系 人：</td>
					<td>{$user[truename]} （{if $user[gender]==1}先生{else}女士{/if}）</td>
				</tr>
				{/if}
				{if $user[department]}
				<tr>
					<td class="i_user_l">部门职位：</td>
					<td>{$user[department]}{if $user[career]} （{$user[career]}）{/if}</td>
				</tr>
				{/if}
				{if $user[mobile]}
				<tr>
					<td class="i_user_l">手机号码：</td>
					<td>{$user[mobile]}{if $DT[sms] && $user[vmobile]}&nbsp;&nbsp;<a href="sms.php?action=add&auth={Crypt::encode($user[mobile])}" target="_blank"><img src="{CSSIMG_URL}/common/sendsms.gif" align="absmiddle" title="发送短信" alt=""/></a>{/if}</td>
				</tr>
				{/if}
				{/if}
				{if $type == 2 && $chat[forward]}
				<tr>
					<td class="i_user_l">来源页面：</td>
					<td><a href="{$chat[forward]}" target="_blank" class="l">点击访问</a></td>
				</tr>
				{/if}
			</table>
		</div>
	</div>
</div>
<script src="{SITE_URL}file/script/chat.js"></script>
<form method="post" action="chat.php" name="down" id="down" target="send">
	<input type="hidden" name="action" value="down"/>
	<input type="hidden" name="chatid" value="{$chatid}"/>
	<input type="hidden" name="data" value="" id="down_data"/>
</form>
{/if}
</div>
<script type="text/javascript">
	seajs.use(['member'], function (member) {
		member.active('menu_general', 'mchat', 'status_{$status}')
	});
	window.onload = chat_fload;
</script>
{template 'footer', $module}